<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>点击图片放大</title>
    <style>
        /* 隐藏放大后的图片容器，初始状态不显示 */
        #enlargedImageContainer {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.8);
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        /* 放大后的图片样式 */
        #enlargedImage {
            max-width: 80%;
            max-height: 80%;
        }
    </style>
</head>

<body>
<h1>image</h1>
<!-- 原始图片 -->
<img id="originalImage" src="/img/image" alt="示例图片" width="30" height="30">

<div id="enlargedImageContainer">
    <img id="enlargedImage" src="/img/image" alt="放大后的示例图片">
</div>

<script>
    const originalImage = document.getElementById('originalImage');
    const enlargedImageContainer = document.getElementById('enlargedImageContainer');

    // 为原始图片添加点击事件监听器
    originalImage.addEventListener('click', function () {
        // 显示放大后的图片容器
        enlargedImageContainer.style.display = 'flex';
    });

    // 为放大后的图片容器添加点击事件监听器，用于关闭放大效果
    enlargedImageContainer.addEventListener('click', function () {
        // 隐藏放大后的图片容器
        this.style.display = 'none';
    });
</script>
</body>

</html>